JPEG method using a discrete cosine transform and another method using Wavelet transformation have been frequently adopted as a compressing method for a still image. As these types of coding method are variable-length coding method, quantity of codes varies for each image to be coded.
In JPEG method of an international standardized method, only a single set of quantization matrices can be defined for an image, thus, quantity of codes cannot be adjusted without a pre-scan. Therefore, a memory may be overflowed when the method is used in a system with limited memory.
To prevent this overflow, enough memory should be reserved, though image to be input can be not the same in size. Therefore, memory, which can be adapted to the largest possible size of images to be input, has to be reserved in the conventional art.
However, in a device that reserves memory matching an image of the largest size, a smaller size of image is meant to be input in that reserved memory, which is far from effective use of memory.
There is an idea to reserve memory matching an image of the medium size. In this case, code data obtained from a coding process overflows the memory.
As a solution to this problem, there have been methods for rereading an original copy with another compression ratio when an actual quantity of codes exceeds an expected quantity of codes, or for resetting a quantization parameter for adjusting quantity of codes by previously estimating quantity of codes with pre-scanning.
As a method for controlling quantity of codes with pre-scanning, there has been a method for inputting pre-compressed data in an inner buffer memory, expanding this piece of data, altering a compression parameter, performing a main compression, and outputting the compressed data to an external memory. In this case, the main compression should be higher in compression ratio than the pre-compression.
However, a compression buffer with a compression ratio more than a target compression ratio has been needed for a compression buffer. This necessitates an enough capacity for recording a piece of original data in order to prevent an overflow of a buffer that is used in the middle of the procedure.
Moreover, a method of repeating a coding process has had another problem that consecutive processing does not speed up because processes for decoding and recompressing are performed for all pieces of compressed data.